package chaoyue.study.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * JDBC
 * 目前版本的连接包中引入了SPI机制
 * 只要引入的驱动包就会自动完成驱动注册
 */
public class Test1_GetConnection3 {
    public static void main(String[] args) throws Exception {
        String url = "jdbc:mysql://127.0.0.1:3306/jdbc-study";
        String username = "root";
        String password = "123456";

        // 直接获取连接
        // getConnection中会先通过ensureDriversInitialized方法确保驱动已经加载
        Connection connection = DriverManager.getConnection(url, username, password);
        System.out.println(connection);
    }
}
